<?php
/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */


/**
 * Primitive OAuth backing store that doesn't do much.
 */
class BasicOAuthDataStore extends OAuthDataStore {

  function lookup_consumer($consumer_key) {
    return new OAuthConsumer($consumer_key, "fake-consumer-secret");
  }

  function lookup_token($consumer, $token_type, $token) {
    if ($token_type == "request") {
      return new OAuthToken($token, "fake-request-secret");
    } elseif ($token_type == "access") {
      return new OAuthToken($token, "fake-access-secret");
    } else {
      throw new OAuthException("unexpected token type: $token_type");
    }
  }

  function lookup_nonce($consumer, $token, $nonce, $timestamp) {
    return false; // pretend we've always never seen this nonce 
  }

  function new_request_token($consumer) {
    return new OAuthToken("fake-request-token", "fake-request-secret");
  }

  function new_access_token($oauthToken, $consumer) {
    return new OAuthToken("fake-access-token", "fake-access-secret");
  }

  function authorize_request_token($token) {  // mark the given request token as having been authorized by the user
  }
}
